<template>
	<view class="page ex-mall-tab-page" >
		<view class="top" >
			<view class="avatar">
				<image style="width: 100%; height: 100%;" src="../../static/mylogo.jpg"></image>
			</view>
			<view class="name">游客(已推广{{userInfo.promotionNumber}}人)</view>
		</view>
		<view class="content">
			<view class="list">
				<view class="item" @click="getintegral">
					<view class="left">
						<view class="icon-box">
							<text class="icon ri-file-list-2-line"></text>
						</view>
						<view class="title">我有({{userInfo.integral}})积分</view>
					</view>
					<view class="right">
						<view class="arrow">
							<text class="icon ri-arrow-right-s-line"></text>
						</view>
					</view>
				</view>
				<!-- #ifdef H5 -->
					<button @click="showWeChat" style="margin-top: 20px;">联系客服</button>
				<!-- #endif -->
				<!-- 
				<view class="item" >
					<view class="left">
						<view class="icon-box">
							<text class="icon ri-settings-5-line"></text>
						</view>
						<view class="title">我的设置</view>
					</view>
					<view class="right">
						<view class="arrow">
							<text class="icon ri-arrow-right-s-line"></text>
						</view>
					</view>
				</view> -->
			</view>
		</view>
	</view>
</template>

<script>
	import {mapState} from 'vuex'
	export default {
		computed: {
			...mapState({
				hasLogin:'hasLogin',
				userInfo: 'userInfo'
		   })
		},
		onLoad() {
			//#ifdef MP
			wx.showShareMenu({
			  withShareTicket: true,
			  menus: ['shareAppMessage', 'shareTimeline']
			})
			//#endif
		},
		onShow() {
			uniCloud.callFunction({
				name: 'user-center',
				data: {
					action:'getUserInfo'
				}
			}).then(res=>{
				this.$store.commit('login',res.result.userInfo)
			})
		},
		data() {
			return {
				
			}
		},
		onShareTimeline: function() {
		  	return {
				title: '这里有好多饿了么美团优惠券，快来领券吧~~',
				path: '/pages/discount/index?invitation='+this.userInfo._id,
				imageUrl: this.shareImage
		  	}
		},
		methods: {
			showWeChat(){
				uni.previewImage({
					urls: [this.contactImage]
				});
			},
			setUser(info){
				console.log(info.target.userInfo)
				uniCloud.callFunction({
					name: 'user-center',
					data: {
						action:'updateUser',
						params: info.target.userInfo
					}
				})
			},
			goAbout() {
				uni.navigateTo({
					url: '/pages/about/index'
				});
			},
			getintegral(){
				uni.showModal({
					title: '获取积分',
					content: '转发小程序给微信好友或微信群，好友点击使用(登录授权)后即算邀请成功；成功邀请1位好友可获得100积分等同于1元，邀请好友及获取积分无上限。',
					showCancel: false
				});
			}
		}
	}
</script>

<style lang="scss">
	page{
		height: 100%;
	}
	.page {
		height: 100%;
		background-color: #F7F7F7;
		&>.top {
			display: flex;
			flex-direction: column;
			align-items: center;
			padding: 78px 0 42px 0;
			border-radius: 0 0 2em 2em;
			background-color: white;
			&>.avatar {
				width: 108px;
				height: 108px;
				border-radius: 24px;
				background-color: #E5AD8B;
			}

			&>.name {
				margin-top: 24px;
				font-size: 17px;
				font-weight: 600;
			}

			&>.label {
				margin-top: 18px;
				font-size: 14px;
			}
		}

		&>.content {
			&>.list {
				padding: 0 28px;

				&>.item {
					display: flex;
					justify-content: space-between;
					align-items: center;
					height: 84px;
					margin-top: 18px;
					padding: 0 24px;
					background-color: #FFFFFF;
					border-radius: 12px;

					&>.left {
						display: flex;
						align-items: center;

						&>.icon-box {
							display: flex;
							justify-content: center;
							align-items: center;
							width: 38px;
							height: 48px;
							border-radius: 12px;

							&>.icon {
								font-size: 18px;
								color: #FFFFFF;
							}
						}

						&>.title {
							margin-left: 18px;
							font-size: 14px;
							font-weight: 600;
							color: #292929;
						}
					}

					&:nth-child(3n-2) {
						&>.left {
							&>.icon-box {
								background-color: #FFC592;
							}
						}
					}

					&:nth-child(3n-1) {
						&>.left {
							&>.icon-box {
								background-color: #F76842;
							}
						}
					}

					&:nth-child(3n) {
						&>.left {
							&>.icon-box {
								background-color: #61DAD5;
							}
						}
					}

					&>.right {
						display: flex;
						align-items: center;

						&>.arrow {
							display: flex;
							align-items: center;

							&>.icon {
								font-size: 18px;
								font-weight: 600;
								color: #9093A2;
							}
						}
					}
				}
			}
		}
	}
	.head{
		background-color: #FFFFFF;
		padding: 40upx;
		margin-bottom: 30upx;
		display: flex;
		flex-direction: row;
		align-items: center
	}
	.head-picture{
		width: 100upx;
		height: 100upx;
		background: #fff;
		border: 5upx solid #fff;
		border-radius: 50%;
		overflow: hidden;
	}
	.nickname{
		margin-left: 30upx;
		font-size: 36upx;
		font-weight: 500;
		text-align: left;
	}
</style>